package main

import (
	"bytes"
	"fmt"
	"regexp"
)

func main() {
	match, _ := regexp.MatchString("p([a-z]+)ch", "peach")
	fmt.Println(match)

	r, _ := regexp.Compile("p([a-z]+)ch")
	fmt.Println(r)
	fmt.Println(r.MatchString("peach"))

	fmt.Println(r.FindString("peach punch"))

	fmt.Println(r.FindStringIndex(" peach punch"))

	fmt.Println(r.FindStringSubmatch("peach punch"))

	fmt.Println(r.FindStringSubmatchIndex("peach punch"))

	s := "peach punch pinch"
	fmt.Println(r.FindAllString(s, -1))

	fmt.Println(r.FindAllStringIndex(s, -1))

	fmt.Println(r.FindAllStringSubmatch(s, -1))

	fmt.Println(r.FindAllStringSubmatchIndex(s, -1))

	fmt.Println(r.Match([]byte("peach")))

	r = regexp.MustCompile("p([a-z]+)ch")
	fmt.Println(r)

	fmt.Println(r.ReplaceAllString("a peach", "<fruit>"))

	in := []byte("a perch")

	out := r.ReplaceAllFunc(in, bytes.ToUpper)

	fmt.Println(string(out))

}
